import request from '@/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/blade-anwise/setting/work_list/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: '/api/blade-anwise/setting/work_list/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/api/blade-anwise/setting/work_list/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/blade-anwise/setting/work_list/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/blade-anwise/setting/work_list/submit',
    method: 'post',
    data: row
  })
}

export const importWorkList = (file,  progressFuc) => {
    const form = new FormData();
    form.append("file", file);
    return request({
        headers:{'Content-Type':'multipart/form-data'},
        url: '/api/blade-anwise/setting/work_list/import-work-list',
        method: 'post',
        data: form,
        onUploadProgress:function(progressEvent){
            if (progressFuc) {
                if (progressEvent.total > 0) {
                    progressEvent.percent = progressEvent.loaded / progressEvent.total * 100;
                }
                progressFuc(progressEvent)
            }
        }
    })
}